package edu.gyc.objecthomework;

/**

 File name: YearsToOvertakePhase1.java

 This program is the first step towards a final solution.
  It includes comments that outline the entire solution,
  reads in two species,
  determines which has the lower initial population,
  prints out the name, population and growth rate for the
      species with the lower population,
  followed by the name, population and growth rate for the
      species with the higher population.

 When this program is complete it will do the following:
  Read in the names, populations and growth rates for two
  species and calculate the number of years it will take the one
  with the lower population to overtake the other (or a message that
  it will never have a higher population).

 Preconditions:
  none

 Postconditions:
  Displays either the number of years it takes for the species with the lower
  population to have a population greater than the other,
  or a message that it will not exceed the other
  species' population within ten years.

 Author: Lew Rakocy
 email address: Lrakocy@devrycols.edu
 Date: <2/20/99>
 Last changed: 8/26/00 Changed methods to those in the newer
	version of Species.

*/

 public class YearsToOvertakePhase1
 {
    public static void main(String[] args)
    {
       Species s1 = new Species();
       Species s2 = new Species();
       Species lower = new Species(); // the one with lower initial population
       Species higher = new Species(); // the one with higher initial population

       // read in one species
       s1.readInput();

       // read in second species
       s2.readInput();

       // determine which has the lower population
       if(s1.getPopulation() < s2.getPopulation())
       {
           lower.set(s1.getName(), s1.getPopulation(),
                     s1.getGrowthRate());
           higher.set(s2.getName(), s2.getPopulation(),
                      s2.getGrowthRate());
       }
       else
       {
           lower.set(s2.getName(), s2.getPopulation(),
                     s2.getGrowthRate());
           higher.set(s1.getName(), s1.getPopulation(),
                      s1.getGrowthRate());
       }

       // test: these lines can be deleted after this first stage program works
       System.out.println("The species that has the lower "
              + "initial population is");
       lower.writeOutput();
       System.out.println("The species with the higher population is");
       higher.writeOutput();
       // end of test

       // find number of years it takes for the species with
       // lower initial population to overtake the other species.
    }
 }

